<template>
	<view></view>
</template>

<script>
	import {myRequest} from '../../utils'
	
	export default {
		data() {
			return {
				
			}
		},
		onShow() {
			let that = this
			
			uni.showLoading({
			    title: '正在登录...',
				success() {
					uni.login({
						provider: 'weixin',
						success: function(loginRes) {
							myRequest({
								url: '/api/user/login',
								data: {code: loginRes.code}
							}, function(res) {
								uni.hideLoading()
								
								if (res.statusCode != 200) {
									that.isShowList = false
									uni.showModal({
										title: '提示',
										content: '服务器错误，请求失败'
									})
									return
								}
								
								if (res.data.status != 0) {
									uni.showModal({
										title: '提示',
										content: res.data.msg
									})
									return
								}
								
								uni.setStorageSync('sessionid', res.data.data.session_id)
								uni.navigateBack()
							})
						}
					})
				}
			})
		},
	}
</script>

<style>
	
</style>
